home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / man-db.postinst < prev    next >
Encoding:
Text File  |  2007-04-05  |  4.0 KB  |  132 lines

  1. #!/bin/sh -e
  2.  
  3. [ "$1" = configure ] || exit 0
  4.  
  5. oldcatdir=/var/catman
  6. catdir=/var/cache/man
  7. maybesetuid='man mandb'
  8. conffile=/etc/manpath.config
  9.  
  10. . /usr/share/debconf/confmodule
  11. db_version 2.0
  12. db_get man-db/install-setuid
  13.  
  14. # Sorry about this, but #98224 is right - statoverrides don't work as
  15. # cleanly as I'd hoped here. I'm going to have to carry around some cruft
  16. # for a while.
  17. for x in $maybesetuid; do
  18.     if dpkg --compare-versions "$2" eq 2.3.18-4 && \
  19.         [ "`dpkg-statoverride --list /usr/lib/man-db/$x`" = \
  20.           "man root 4755 /usr/lib/man-db/$x" ]; then
  21.     dpkg-statoverride --remove /usr/lib/man-db/$x
  22.     fi
  23. done
  24.  
  25. if [ "$RET" = true ]; then
  26.     # man and mandb are to be installed setuid man.
  27.     owner=man:root
  28.     mode=4755
  29. else
  30.     # man and mandb are not to be installed setuid.
  31.     owner=root:root
  32.     mode=0755
  33. fi
  34.  
  35. for x in $maybesetuid; do
  36.     # No statoverrides available or none exist for us ...
  37.     if [ ! -x /usr/sbin/dpkg-statoverride ] || \
  38.         ! dpkg-statoverride --list /usr/lib/man-db/$x >/dev/null; then
  39.     chown $owner /usr/lib/man-db/$x
  40.     chmod $mode  /usr/lib/man-db/$x
  41.     fi
  42.     ln -sf ../lib/man-db/$x /usr/bin/$x
  43. done
  44.  
  45. if [ -e /etc/cron.daily/man.moved-by-preinst ]; then
  46.     rm /etc/cron.daily/man.moved-by-preinst
  47. fi
  48. if [ -e /etc/cron.weekly/catman.moved-by-preinst ]; then
  49.     rm /etc/cron.weekly/catman.moved-by-preinst
  50. fi
  51.  
  52. if dpkg --compare-versions "$2" lt 2.3.18; then
  53.     # /usr/local/man now mapped to /var/cache/man/oldlocal
  54.     if [ -d $catdir/local ] && [ ! -d $catdir/oldlocal ]; then
  55.     mv -f $catdir/local $catdir/oldlocal
  56.     fi
  57. fi
  58.  
  59. if [ -d $catdir ]; then
  60.     # Catdirs sometimes used to be created with the wrong permissions.
  61.     if dpkg --compare-versions "$2" lt 2.3.20-4; then
  62.     chown -R man /var/cache/man
  63.     fi
  64. else
  65.     # Old packages removed catpages on upgrade. The preinst hack should have
  66.     # avoided this, but let's be sure.
  67.     install -d -o man -g root -m 02755 $catdir
  68. fi
  69.  
  70. build_db=0
  71.  
  72. if dpkg --compare-versions "$2" lt 2.3.16 || \
  73.    ([ ! -f $catdir/index.db ] && [ ! -f $catdir/index.bt ]); then
  74.     # If the build-database question was never asked, this is probably a
  75.     # fresh install, or maybe we're reconfiguring. The default is to build
  76.     # the database.
  77.     db_fget man-db/build-database seen
  78.     if [ "$RET" = false ]; then
  79.     build_db=1
  80.     else
  81.     # This should probably only fire when upgrading from less than
  82.     # 2.3.16, but it doesn't really matter.
  83.     db_get man-db/build-database
  84.     if [ "$RET" = true ]; then
  85.         build_db=1
  86.     fi
  87.     fi
  88. elif dpkg --compare-versions "$2" lt 2.4.2-1; then
  89.     # Clean up old btree databases from before 2.4.2-1. They're useless now.
  90.     find /var/cache/man -name index.bt -print0 | xargs -0r rm -f
  91.  
  92.     db_get man-db/rebuild-database
  93.     if [ "$RET" = true ]; then
  94.     build_db=1
  95.     fi
  96. fi
  97.  
  98. if [ $build_db -eq 1 ]; then
  99.     frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  100.     if [ "$frontend" = noninteractive ]; then
  101.     # Run in the foreground. In this case, chances are we're being run
  102.     # from debootstrap, which will have problems if mandb runs
  103.     # backgrounded for too long (bug #100616).
  104.     # start-stop-daemon isn't available when running from debootstrap.
  105.     echo "Building database of manual pages ..." >&2
  106.     perl -e '@pwd = getpwnam("man"); $( = $) = $pwd[3]; $< = $> = $pwd[2];
  107.              exec "/usr/bin/mandb", "-cq"' || true
  108.     else
  109.     echo "Building database of manual pages in the background." >&2
  110.     # --pidfile /dev/null so it always starts; mandb isn't really a
  111.     # daemon, but we want to start it like one.
  112.     start-stop-daemon --start --pidfile /dev/null --background \
  113.               --startas /usr/bin/mandb --oknodo --chuid man \
  114.               -- --create --quiet
  115.     fi
  116. fi
  117.  
  118. # Automatically added by dh_installdocs
  119. if [ "$1" = configure ] && which install-docs >/dev/null 2>&1; then
  120.     install-docs -i /usr/share/doc-base/man-db
  121. fi
  122. # End automatically added section
  123.  
  124.  
  125. # The upgrade is complete, so no more concern about this question being
  126. # asked twice. Clean up the flag.
  127. db_fset man-db/rebuild-database seen_in_2.4.2-1_upgrade false
  128.  
  129. db_stop
  130.  
  131. exit 0
  132.